#pragma once
#include "Fysics/Dependencies.h"
#include "Fysics/Event/Event.h"
#include "Fysics/System/Base.h"

#include <glm/glm.hpp>

namespace Fysics
{
	enum class ObjectState
	{
		START,
		RUNNING,
		SLEEP,
		DESTROY
	};

	enum ObjectType
	{
		NONE = BIT(0),
		ITEM = BIT(1),
		PLANE = BIT(2)
	};

	class IComponent;

	class Object
	{
	private:
		std::string m_ID;
		std::string m_Name;
		ObjectState m_State;
		int m_Type;
		std::vector<IComponent*> m_ComponentList;
	protected:
		glm::vec3 m_Position;
		glm::vec3 m_Rotation;
		glm::vec3 m_Scaling;

		void SetType(ObjectType type);
	public:
		Object(const std::string& id, const std::string& name, 
			const glm::vec3& position, const glm::vec3& rotation, const glm::vec3& scaling);
		virtual ~Object();

		std::string GetID() const { return m_ID; }
		std::string GetName() const { return m_Name; }
		bool IsType(ObjectType type) const;
		void SetID(const std::string& id) { m_ID = id; }
		void SetName(const std::string& name) { m_Name = name; }

		void SetPosition(const glm::vec3& position) { m_Position = position; }
		void SetRotation(const glm::vec3& rotation) { m_Rotation = rotation; }
		void SetScaling(const glm::vec3& scaling) { m_Scaling = scaling; }

		glm::vec3 GetPosition() const { return m_Position; }

		virtual void OnEvent(Event& event) {}

		void Run();
		void AttachComponent(IComponent* component);
		glm::mat4 GetModelMatrix() const;
		virtual void Draw() const = 0;
	};
}